import Vue from 'vue'
import VueRouter from 'vue-router'
// import store from '@/store'
//主页面
import LayoutMain from '@/layout/main' 
import MainNav from '@/contents/MainLayout/MainNav'
  

//登录注册
import LoginPage from '@/pages/LoginPage'
import RegisterPage from '@/pages/RegisterPage'
//contents布局
import LayoutFunc from '@/layout/office' 
import PersonalMetting from '@/contents/Functions/PersonalMetting'
import PersonalNotice from '@/contents/Functions/PersonalNotice'


Vue.use(VueRouter)

const routes = [
  {
    path: '/office',
    name: 'office',
    component: LayoutFunc,
    children: [
        {
          path: 'metting',
          name: 'personalMetting',
          component: PersonalMetting
        },
      
        {
          path: 'notice',
          name: 'personalNotice',
          component: PersonalNotice
        },
      
    ]
  },
  {
    path: '/main',
    name: 'main',
    component: LayoutMain,
    children: [
        {
          path: 'nav',
          name: 'mainNav',
          component: MainNav
        },
    ]
  },
  {
    path: '/login',
    name: 'LoginPage',
    component: LoginPage,
  },
  {
    path: '/register',
    name: 'RegisterPage',
    component: RegisterPage,
  }
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]

const router = new VueRouter({
  routes
})

// 不登录就可以放行的路径
// const whiteList = ['/login', '/register']

// router.beforeEach((to, from, next) => {
//   // if(whiteList.includes(to.path)) { //白名单直接放行
//   //   next()
//   // } else { // 验证是否有token
//   //   const token = store.getters['user/token']
//   //   if((!token || !token?.username || !token?.role)) {
//   //     next('/login')
//   //   } else {
//   //     next()
//   //   }
//   // }
//   // alert(from,next)

// })

export default router
